package com.ruoyi.yqhs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yqhs.domain.YqhsQyb;
import com.ruoyi.yqhs.service.IYqhsQybService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 气液比数据Controller
 *
 * @author ruoyi
 * @date 2025-08-31
 */
@RestController
@RequestMapping("/yqhs/qyb")
public class YqhsQybController extends BaseController {
    @Autowired
    private IYqhsQybService yqhsQybService;

    /**
     * 查询气液比数据列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qyb:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqhsQyb yqhsQyb) {
        startPage();
        List<YqhsQyb> list = yqhsQybService.selectYqhsQybList(yqhsQyb);
        return getDataTable(list);
    }

    /**
     * 导出气液比数据列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qyb:export')")
    @Log(title = "气液比数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqhsQyb yqhsQyb) {
        List<YqhsQyb> list = yqhsQybService.selectYqhsQybList(yqhsQyb);
        ExcelUtil<YqhsQyb> util = new ExcelUtil<YqhsQyb>(YqhsQyb.class);
        util.exportExcel(response, list, "气液比数据数据");
    }

    /**
     * 获取气液比数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qyb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(yqhsQybService.selectYqhsQybById(id));
    }

    /**
     * 新增气液比数据
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qyb:add')")
    @Log(title = "气液比数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqhsQyb yqhsQyb) {
        return toAjax(yqhsQybService.insertYqhsQyb(yqhsQyb));
    }

    /**
     * 修改气液比数据
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qyb:edit')")
    @Log(title = "气液比数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqhsQyb yqhsQyb) {
        return toAjax(yqhsQybService.updateYqhsQyb(yqhsQyb));
    }

    /**
     * 删除气液比数据
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qyb:remove')")
    @Log(title = "气液比数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(yqhsQybService.deleteYqhsQybByIds(ids));
    }

    @GetMapping(value = "getRtInfo/{jyzId}")
    public AjaxResult getRtInfo(@PathVariable("jyzId") Long jyzId) {
        return success(yqhsQybService.getRtInfo(jyzId));
    }


}
